home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
VideoFolder 1.0a
/
Source
/
FSSpecPane.cp
< prev
next >
Wrap
Text File
|
1996-06-21
|
2KB
|
84 lines
#include "MoreFilesExtras.h"
#include "FSSpecPane.h"
FSSpecPane* FSSpecPane::CreateFSSpecPaneStream ( LStream* inStream )
{
return new FSSpecPane ( inStream );
}
FSSpecPane::FSSpecPane ( LStream* inStream ) :
LCaption ( inStream )
{
mSpec.vRefNum = 0;
mSpec.parID = 0;
mSpec.name[0] = 0;
}
void FSSpecPane::DrawSelf ( )
{ Rect frameRect;
if ( CalcPortFrameRect ( frameRect ) )
{
mText = "\p";
Try_
{
long dirID;
Boolean isDirectory;
ThrowIfOSErr_ ( GetDirectoryID( mSpec.vRefNum, mSpec.parID, (StringPtr) mSpec.name, & dirID, & isDirectory ) );
if ( ! isDirectory )
mText = mSpec.name;
Str255 volumeName;
short vRefNum;
long freeBytes;
ThrowIfOSErr_ ( GetVInfo ( mSpec.vRefNum, volumeName, & vRefNum, & freeBytes ) );
if ( StringWidth ( mText ) + StringWidth ( volumeName ) + CharWidth ( ':' ) < frameRect.right - frameRect.left )
{
mText.Insert ( ':', 1 );
mText.Insert ( volumeName, 1 );
}
unsigned char insertionPoint = mText.Length() + 1;
FSSpec spec = mSpec;
while ( spec.parID != 2 )
{
if ( StringWidth ( mText ) < frameRect.right - frameRect.left )
{
ThrowIfOSErr_( FSMakeFSSpec ( spec.vRefNum, spec.parID, "\p", & spec ) );
mText.Insert ( ':', insertionPoint );
mText.Insert ( spec.name, insertionPoint );
}
else
{
mText.Insert ( "\p:…:", insertionPoint );
break;
}
}
}
Catch_( inErr )
{
mText = "\p?";
}
}
LCaption::DrawSelf ();
}
void FSSpecPane::GetFSSpec( FSSpec& outSpec ) const
{
outSpec = mSpec;
}
void FSSpecPane::SetFSSpec( const FSSpec& inSpec )
{
mSpec = inSpec;
Refresh();
}